<!--
 * @Author: wrh123 482597539@qq.com
 * @Date: 2024-01-11 18:07:08
 * @LastEditors: wrh123 482597539@qq.com
 * @LastEditTime: 2024-01-22 22:10:20
 * @FilePath: /vue-admin/src/views/Tradingacct/components/control.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <el-dialog title="分控编辑" :visible="showControl" width="30%" :before-close="handleClose">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item prop="passWord" label="是否风控:">
          <el-select v-model="form.fengkongZhuangtai" size="mini" placeholder="请选择是否风控">
            <el-option label="否" :value="0" />
            <el-option label="是" :value="1" />
          </el-select>
        </el-form-item>

        <el-form-item label="风控服务器" label-width="120px">
          <el-input placeholder="请输入风控服务器" size="mini" v-model="form.fengkongServers" />
        </el-form-item>

        <el-form-item label="风控负责人" label-width="120px">
          <el-input placeholder="请输入风控负责人" size="mini" v-model="form.fengkongPrincipal" />
        </el-form-item>
      </el-form>
      <el-row type="flex" justify="center" style="margin-top: 20px;">
        <el-button size="mini" @click="handleClose">取 消</el-button>
        <el-button size="mini" type="primary" @click="delBtnOK">确 定</el-button>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
import { updateStatus } from '@/api/Tradingacct'
export default {
  name: 'VueAdminControl',
  props: {
    showControl: {
      default: false,
      type: Boolean
    },
    controlId: {
      default: null,
      type: Number
    }
  },
  data() {
    return {
      form: {
        fengkongZhuangtai: 0, // 
        fengkongPrincipal: "",  // 风控负责人
        fengkongServers: "", // 风控服务器 
        id: null
      },
      rules: {}
    }
  },
  watch: {
    controlId(old, nev) {
      this.form.id = old
    }
  },

  mounted() {
  },

  methods: {
    // 取消
    async handleClose() {
      this.$refs.form.resetFields()
      this.$emit('update:showControl', false)
    },
    // 确定
    async delBtnOK() {
      await this.$refs.form.validate()
      this.$confirm('请确认服务器上的密码是否已经修改?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        const res = await updateStatus(this.form)
        // 调用直接修改分控的接口
        this.$message({
          type: 'success',
          message: '风控修改成功'
        })
        this.$emit('refresh')
        this.handleClose()
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消修改'
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
